#ifndef HTTPCLIENT_H
#define HTTPCLIENT_H

#include <QtCore/QObject>
#include <QtCore/QPair>
#include <QtCore/QString>
#include <QtCore/QByteArray>
#include <QtNetwork/QHttp>
#include <QtNetwork/QHttpRequestHeader>

class HttpClient : public QObject
{
    Q_OBJECT
public:
    HttpClient(QString host, int port);
    ~HttpClient();
    void setConnectionInfo(QString host, int port);
    void setProxyInfo(bool useProxy, QString proxyHost, int proxyPort,
                      bool useProxyAuth, QString proxyUser, QString proxyPass);
    void doRequest(QString url); // GET
    void doRequest(QString url, QByteArray content); // POST

    QByteArray m_data;
    QString m_cookies;
    int response;
    QString responseMsg;
private:
    QHttp *m_http;
    QString m_host;
public slots:
    void done(bool error);
    void responseHeaderReceived(const QHttpResponseHeader &resp);
signals:
    void requestDone(QByteArray *data);
    void requestError(QString message);
};

#endif // HTTPCLIENT_H
